/*    */ package cc.s2m.web.s2mBlog.controller;
/*    */ 
/*    */ import cc.s2m.util.Page;
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.ArticlesTags;
/*    */ import cc.s2m.web.s2mBlog.pojo.Tags;
/*    */ import cc.s2m.web.s2mBlog.service.IArticles;
/*    */ import cc.s2m.web.s2mBlog.service.IArticlesTags;
/*    */ import cc.s2m.web.s2mBlog.service.ITags;
/*    */ import cc.s2m.web.s2mBlog.vo.Expressions;
/*    */ import cc.s2m.web.s2mBlog.vo.VO;
/*    */ import com.google.common.collect.Lists;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller("TagsController")
/*    */ public class TagsController extends BaseController
/*    */ {
/* 29 */   public static int PAGE_NUMBER = 10;
/*    */ 
/*    */   @Autowired
/*    */   private ITags tagsService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticles articlesService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticlesTags articlesTagsService;
/*    */ 
/* 40 */   @RequestMapping({"/tags"})
/*    */   public String list(Model model) { Map map = new HashMap();
/* 41 */     map.put("orderBy", "number DESC");
/* 42 */     List list = this.tagsService.getList(null, map);
/* 43 */     model.addAttribute("list", list);
/* 44 */     return "tags"; }
/*    */ 
/*    */   @RequestMapping({"/tags/{tag}"})
/*    */   public String tag(Model model, @PathVariable String tag)
/*    */   {
/* 49 */     Map map = new HashMap();
/* 50 */     Tags tagsVo = new Tags();
/* 51 */     tagsVo.setUrl(tag);
/* 52 */     Tags tags = (Tags)this.tagsService.getByCondition(tagsVo);
/* 53 */     if (tags == null) {
/* 54 */       return "404";
/*    */     }
/* 56 */     model.addAttribute("tagBean", tags);
/* 57 */     ArticlesTags atagVO = new ArticlesTags();
/* 58 */     atagVO.setTid(tags.getId());
/* 59 */     List<ArticlesTags> atags = this.articlesTagsService.getList(atagVO, null);
/* 60 */     List sids = Lists.newArrayList(new Integer[] { Integer.valueOf(0) });
/* 61 */     for (ArticlesTags atag : atags) {
/* 62 */       sids.add(atag.getAid());
/*    */     }
/* 64 */     VO vo = new VO();
/* 65 */     vo.and(Expressions.in("id", sids));
/* 66 */     map.put("vo", vo);
/*    */ 
/* 68 */     Page pageBean = this.articlesService.getPage(1, PAGE_NUMBER, "/tags/" + tag + "/", map);
/* 69 */     model.addAttribute("pageBean", pageBean);
/* 70 */     return "index";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/tags/{tag}/page/{page}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String page(Model model, @PathVariable String tag, @PathVariable Integer page) {
/* 75 */     Map map = new HashMap();
/* 76 */     Tags tagsVo = new Tags();
/* 77 */     tagsVo.setUrl(tag);
/* 78 */     Tags tags = (Tags)this.tagsService.getByCondition(tagsVo);
/* 79 */     if (tags == null) {
/* 80 */       return "404";
/*    */     }
/* 82 */     model.addAttribute("tagBean", tags);
/* 83 */     ArticlesTags atagVO = new ArticlesTags();
/* 84 */     atagVO.setTid(tags.getId());
/* 85 */     List<ArticlesTags> atags = this.articlesTagsService.getList(atagVO, null);
/* 86 */     List sids = Lists.newArrayList();
/* 87 */     for (ArticlesTags atag : atags) {
/* 88 */       sids.add(atag.getAid());
/*    */     }
/* 90 */     VO vo = new VO();
/* 91 */     vo.and(Expressions.in("id", sids));
/* 92 */     map.put("vo", vo);
/*    */ 
/* 94 */     Page pageBean = this.articlesService.getPage(page.intValue(), PAGE_NUMBER, "/tags/" + tag + "/", map);
/* 95 */     model.addAttribute("pageBean", pageBean);
/* 96 */     return "index";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.TagsController
 * JD-Core Version:    0.6.1
 */